<?php

$result="";

if(isset($_POST['action']) && !empty($_POST['action'])) {
	$action = $_POST['action'];
	switch($action) {
		case 'test' : 
			$result=test();
			break;
		case 'sum' :
			$result=sum();
		break;	
	}
}

echo $result;

function test(){
	$valutazione=rand(0, 100000);
	$res = json_encode($valutazione);
	return $res;
}

function sum(){
	$a = $_POST["a"];
	$b = $_POST["b"];
	$c = $_POST["c"];
	$res = $a+$b+$c;
	return $res;
}

?>